﻿namespace HRM.CORE
{
    using DevExpress.XtraEditors;
    
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;
    using APP.HELPER.Utils.Language;

    public class xfmShiftOrder : XtraForm
    {
        private IContainer components;
        private xucShiftOrder x_ShiftOrder;

        public event ClosedHandler Closed;

        public event SaveDataChangedHander SaveDataChanged;

        public xfmShiftOrder()
        {
            this.components = null;
            this.InitializeComponent();
            this.Text = MultiLanguages.GetString("tbl_ShiftOrder", "ShiftOrder", this.Text);
            this.x_ShiftOrder = new xucShiftOrder();
            this.x_ShiftOrder.Dock = DockStyle.Fill;
            this.x_ShiftOrder.SaveDataChanged += new xucShiftOrder.SaveDataChangedHander(this.x_ShiftOrder_SaveDataChanged);
            base.Controls.Add(this.x_ShiftOrder);
        }

        public xfmShiftOrder(int Month, int Year)
        {
            this.components = null;
            this.InitializeComponent();
            this.Text = MultiLanguages.GetString("tbl_ShiftOrder", "ShiftOrder", this.Text);
            this.x_ShiftOrder = new xucShiftOrder(Month, Year);
            this.x_ShiftOrder.Dock = DockStyle.Fill;
            this.x_ShiftOrder.SaveDataChanged += new xucShiftOrder.SaveDataChangedHander(this.x_ShiftOrder_SaveDataChanged);
            base.Controls.Add(this.x_ShiftOrder);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x3f0, 0x232);
            base.MinimizeBox = false;
            base.Name = "xfmShiftOrder";
            base.ShowIcon = false;
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterParent;
            this.Text = "Bảng Xếp Ca";
            base.WindowState = FormWindowState.Maximized;
            base.FormClosing += new FormClosingEventHandler(this.xfmShiftOrder_FormClosing);
            base.ResumeLayout(false);
        }

        private void RaiseClosedHandler()
        {
            if (this.Closed != null)
            {
                this.Closed(this);
            }
        }

        private void RaiseSaveDataChangedHander()
        {
            if (this.SaveDataChanged != null)
            {
                this.SaveDataChanged(this);
            }
        }

        public void SetData(int Month, int Year)
        {
            if (this.x_ShiftOrder == null)
            {
                base.Controls.Clear();
                this.x_ShiftOrder = new xucShiftOrder(Month, Year);
                this.x_ShiftOrder.Dock = DockStyle.Fill;
                this.x_ShiftOrder.SaveDataChanged += new xucShiftOrder.SaveDataChangedHander(this.x_ShiftOrder_SaveDataChanged);
                base.Controls.Add(this.x_ShiftOrder);
            }
            else
            {
                this.x_ShiftOrder.SetData(Month, Year);
            }
        }

        private void x_ShiftOrder_SaveDataChanged(object sender)
        {
            this.RaiseSaveDataChangedHander();
        }

        private void xfmShiftOrder_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.RaiseClosedHandler();
        }

        public delegate void ClosedHandler(object sender);

        public delegate void SaveDataChangedHander(object sender);
    }
}

